/*
 * qcarpcdialog.h - elements GUI for qcarpc
 *
 * Copyright (C) 2010-2011 Serge Begger
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef QCARPCDIALOG_H
#define QCARPCDIALOG_H

#include <QWidget>
#include <QFrame>
#include <QScrollBar>
#include <QGridLayout>
#include <QLineEdit>
#include <QLabel>
#include <QSignalMapper>
#include <QPushButton>
#include <QTime>
#include <QTimer>
#include <QPropertyAnimation>
#include <QMessageBox>
#include <QProgressBar>
#include <QEventLoop>
#include <QPainter>
#include <QDir>
#include <QFile>
#include <QTextStream>

class myProgressbar : public QWidget
{
Q_OBJECT
public:
    explicit myProgressbar(QWidget *parent = 0, QString = "");
    ~myProgressbar();
    void start();
    void stop();
    void setText(QString);

public slots:
    void updateSlider();

private:
    int LRValue;
    QTimer *timer;
    QWidget *centralWidget;
    QFrame *frame;
    QLabel *label;
    QProgressBar *hProgressBar;

};

class numPanel : public QWidget
{
Q_OBJECT
public:
   numPanel(QWidget *parent = 0, bool freqpanel = false, QRect pangmtr = QRect(0,0,400,300));
        ~numPanel();
        QString *freq;
        QLabel *helpLabel;
        int maxSymb;
        QPushButton *numAsButton;
        QPushButton *numNoButton;

    private:
        QSignalMapper *mapper;
        QWidget *formLayoutWidget;
        QGridLayout *gridLayout;
        QPushButton *num1Button, *num2Button, *num3Button, *num4Button, *num5Button, *num6Button, *num7Button, *num8Button, *num9Button, *num0Button;
        QPushButton *dellButton;
        QPropertyAnimation *animation;
        bool typePanel;
        QRect gmtr;

    signals:
        void putFreq();
        void endPutFreq();

    public slots:
        void onShow();
        void offShow();

    private slots:
        void pressedButtons(QString);
        void closeNumPanel();
        void numAs();
        void endTimer();
        void animFinished();
};

class myMessage : public QWidget
{
    Q_OBJECT
    public:
         myMessage(QWidget * parent = 0);
         bool result;
         void exec(int , QString);

    private:
         QEventLoop *eventLoop;
         QFrame *frame;
         QLabel *labelIcon;
         QLabel *labelText;
         QPushButton *ok_button, *cancel_button;

     private slots:
        void ok_button_pressed();
        void cancel_button_pressed();
};

class gslider : public QFrame
{
    Q_OBJECT
public:
    explicit gslider(QWidget *parent = 0, bool horizontal = false);
    ~gslider();
    double value();
    double maximum();
    double minimum();
signals:

public slots:
    void setValue(double);
    void setMaxValue(double);
    void setMinValue(double);

private:
    double currValue, minValue, maxValue;
    bool isHorizontal;
    void paintBar();
    void paintGrid();
    void paintTriangle();
    void paintLine();

protected:
    void paintEvent(QPaintEvent *);

};

class qcarpclog : public QObject {
    Q_OBJECT
public:
    explicit qcarpclog(QObject *parent = 0);
    ~qcarpclog();
    void append(QString module,QString text);
private:
    QFile *logfile;
    bool logopen;
};

#endif // QCARPCDIALOG_H
